/*
* ============================================================================
*  Name     : IconFileProvider.cpp
*  Part of  : GV60
*  Copyright: Wipo Software
* ============================================================================
*/

#include "IconFileProvider.h"

CIconFileProvider::CIconFileProvider(RFs aSession) :
  iSession(aSession)
{
}

CIconFileProvider* CIconFileProvider::NewL(RFs aSession, const TDesC& aFilename)
{
  CIconFileProvider* self = new (ELeave) CIconFileProvider(aSession);
  CleanupStack::PushL(self);
  self->ConstructL(aFilename);
  CleanupStack::Pop(); // self
  return self;
}

CIconFileProvider* CIconFileProvider::NewLC(RFs aSession, const TDesC& aFilename)
{
  CIconFileProvider* self = new (ELeave) CIconFileProvider(aSession);
  CleanupStack::PushL(self);
  self->ConstructL(aFilename);
  return self;
}

void CIconFileProvider::ConstructL(const TDesC& aFilename)
{
  pFilename = aFilename.AllocL();
}

CIconFileProvider::~CIconFileProvider()
{
  if (pFilename)
  {
    delete pFilename;
  }
}

void CIconFileProvider::RetrieveIconFileHandleL(RFile& aFile, const TIconFileType aType)
{
  TFileName filename;

  filename = pFilename->Des().Left(pFilename->Length() - 3);

  if (aType == EMifFile)
  {
    _LIT(KMif, "mif");
    filename.Append(KMif);
  }
  else // mbm
  {
    _LIT(KMbm, "mbm");
    filename.Append(KMbm);
  }

	User::LeaveIfError(aFile.Open(iSession, filename, EFileShareAny));
}

void CIconFileProvider::Finished()
{
}

